package com.durian.base.frame.viewbinding

import androidx.activity.ComponentActivity
import androidx.annotation.MainThread
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.durian.base.frame.titlebar.BaseSuperTitleBar

@MainThread
inline fun <reified VM : ViewBinding> ComponentActivity.viewBindings(): Lazy<VM> {
    return ActivityViewBindingLazy(VM::class) { layoutInflater }
}

@MainThread
inline fun <reified VM : ViewBinding> Fragment.viewBindings(): Lazy<VM> {
    return FragmentViewBindingLazy(VM::class) { layoutInflater }
}

@MainThread
inline fun <reified VM : ViewBinding> BaseSuperTitleBar.viewBindings(): Lazy<VM> {
    return TitleBarViewBindingLazy(VM::class) {activity?.layoutInflater!!}
}